//
//  WelcomeViewController.swift
//  swift_learning
//
//  Created by aron on 2017/2/1.
//  Copyright © 2017年 arons. All rights reserved.
//

import UIKit
import SDWebImage

class WelcomeViewController: UIViewController {

    /// 头像
    @IBOutlet weak var avatarImgView: UIImageView!
    
    /// 头像底部约束
    @IBOutlet weak var avatarImgViewBottomCons: NSLayoutConstraint!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // 设置头像
        let avatarUrlString = UserAccountManager.sharedInstance.account?.avatar_large
        avatarImgView.sd_setImage(with: URL(string: avatarUrlString ?? ""), placeholderImage: #imageLiteral(resourceName: "avatar_default_big"))
        
        // 设置动画
        UIView.animate(withDuration: 2, delay: 0.0001, usingSpringWithDamping: 0.5, initialSpringVelocity: 5, options: [], animations: {
            // 1.改变约束的值
            self.avatarImgViewBottomCons.constant = SCREEN_HEIGHT() - 200
            self.view.layoutIfNeeded()
           
        }) { (finished) in
            // 3.将创建根控制器改成Main
            UIApplication.shared.keyWindow?.rootViewController = FLMainViewController()
        }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}
